home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / graphicgems4.lha / GemsIV / dyn_range / hdp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-06  |  1.0 KB  |  41 lines

  1. /*
  2. ** HDP.H : Encoding and Decoding of High Dynamic Range Pixels
  3. */
  4.  
  5. /*
  6. ** Encoding and Decoding Types
  7. */
  8. typedef unsigned char byte;
  9. typedef float real; /* change to "double" if you work with double precision */
  10.  
  11. typedef byte bytecolor[3];
  12. typedef real realcolor[3];
  13.  
  14. /*
  15. ** Encoding and Decoding Tables
  16. */
  17. extern byte *EncodeLut;
  18. extern real *DecodeLut;
  19. extern real  LutScale;
  20.  
  21. /*
  22. ** Encoding and Decoding Functions
  23. */
  24. extern int init_HDP_encode (real,real,int);
  25. extern int init_HDP_decode (real,real,real);
  26. extern void exit_HDP_encode (void);
  27. extern void exit_HDP_decode (void);
  28.  
  29. /*
  30. ** Encoding and Decoding Macros
  31. */
  32. #define HDP_ENCODE(RealColor,ByteColor) ( \
  33.    ByteColor[0] = EncodeLut [(int) (RealColor[0] * LutScale + 0.5)], \
  34.    ByteColor[1] = EncodeLut [(int) (RealColor[1] * LutScale + 0.5)], \
  35.    ByteColor[2] = EncodeLut [(int) (RealColor[2] * LutScale + 0.5)])
  36.  
  37. #define HDP_DECODE(ByteColor,RealColor) ( \
  38.    RealColor[0] = DecodeLut [ByteColor[0]], \
  39.    RealColor[1] = DecodeLut [ByteColor[1]], \
  40.    RealColor[2] = DecodeLut [ByteColor[2]])
  41.